refactor to make it more organized