Using Serial imput to run a code

I have been trying to work through the code but i have hit a wall, it just won't work. It starts fine but it will rarely pause correctly. I think the problem is that it cant check it except while it is not running the sorter code. Is there any way to fix it?

Here is my current code:

MM_Sorter_shift_toggle_servo_count8.ino (10.7 KB)