adding recursive with auxiliary function