Prototype code for Gateway