refactoring - unfinished