small refactoring - removed duplicate code