solving multiple instance problem