Added pause
Continued refactoring to make some sense of the code