removed null check but changed the cast