some AGWPE code (not working yet)