check if  is defined befor accessing  property