a complete refactor