consolidate if statement