refactored after merge