clean the code duplication