refactored code to correct an error