Fix functionality, fix naming issues, added eventlistener instead of onclick and optimise code