wrote recursive part, but not tested