added 'clock' functionality
cleaned up js and added comments