Refactoring to simplify and improve clarity