Added extra if condition to avoid issues