divide logic and functions to seperate js files
improved hide-and-show behaviour of bug