replace nested if's with &&