mega refactor