fix comments, tests, write implementation