refactored for migration