Combining if statements as per @irbrad's suggestion.