implemented refactors from interview