replace if statements with select() method