refactor to work