#27 refactoring function for generating homepy