Refactor to helper file