added very basic range checking