bug fix. small refactoring