refactored but not final