fixed some problem that came from refactoring