code duplication fixed