Removed variable and changed html to document in events