better logic, unit test