updated set length error checking