working needs refactoring