fixing immediate crash issue with uncaught out of range exception