begining refactor