bug fixed, small refactoring #1