modified to work without appengine