need to finish refactoring bad logic