select statement in place of if