Added check for oldval length