Consolidated code for readability