removing duplicated code

just a small refactoring