Cleaned code, added comments and global setInterval var for access across multiple functions