corrected an issue that would cause ErrorException: Undefined offset: 0