fixed checking for inactivity after every step