shorten redundant if statement