Basic "nested if" solution