added stage limit check