Refaced the backend logic. Trying TDD for realz