fixed potential nil check