moved check for out of bounds closer to rendering invocation