some more boundary checking