fixed a bug created after the last refactor