This is the only way I found to have it work in both case: declarative and programmatic.