refactored code so some block of code not needed