working refactor out of multiple files