throw exception if pos is not valid