Added new while loop to begin handling various stages.