bug fix, refactoring