Refactor from scratch