refactor finish, not tested