added some comments, renamed variables for clarity, added pause functionality