refactored code fixes