refactored some code to simplify
added commands pause, resume, next, prev and refactored some code