refactored and moved functions to home controller