refactored code to delete an uneccessary line