moved some code to global event js, should be possible to sum up more