Solve nesting if statement