this should be checked before this function is called.