refactoring and dublication removed