Replace nested if with a guard clause to clean up the code.