refactored code with Charlotte