refactoring.. currently broken