Added register function, tried to move registring and logging in into a seperate file