fix last-minute code rearrangement in last commit that broke the intended functionality