Refactored functions for readability