improved subset solution implementation