Fixed for potential out of bounds exception.