full implementation with a working example