added nesting if