Button input lag

I have a button lag on Mega. I have several sensors (almost all analog) which i power with external power supply 12V/3A 36W. My sensors on Mega is working ok. Mega output values are ok. But button....

I have a button which acts as a switch and is connected with a relay. Button code is working except sometimes i have to keep pressure for a while.

Code for sensors is straight but there are almost 10 of them. And everything is happening in a void loop(). After a while i noticed that i have to "hunt" the time when code with reading sensors is finished and then press button.

Question is: What to do so Mega can doing loops with button code some sort of separate way of code for sensors? So it doesn't depend on time it need to finish readings? It acts some sort of i press the button but Mega isn't still get to that part of the code so it can not see it. If i press the button right it finish readings it is ok.

The problem is in the code you didn't post.

Or in the circuit, a diagram of which is also missing from the post.

For keeping your code responsive: make sure there are no delay() calls, replace those with millis() based timing. Sensors that need time for conversion can be called back later that way, while your code continues to check the buttons and other sensors. Look at Blink Without Delay for an example of how that works, or check the "several things at the same time" thread in the Project Guidance section.