early base gateway code (untested)