try to avoid redundant ifs