You described what you intended to do.
But without seeing your code, your models and your data, there's no way anybody can reason what might not work correctly.
As usual: show the code, show the data, show the problem. Then there's a good chance for help.
- Lars