test version: added out of bounds input check