Added checks for nil for modelItem and height