fixed off-by-0.5 indexing issues