Removing defer methods to a separate file