Added some range checking ability