returning undefined when out of bounds