Rewritten using TDD