added a guard on size()