making conditional statement more robust