corey's refactor