Moves some code to init function