#1 Refactor: Added helper functions and extracted constants