turn into nested if