fix bugs introduced in refactor