fixed scoping bug in AGREE