removing the code duplication