cleaned up code and added polling support
loopback example