check bounds before returning, add test harness