porting to appengine and refactoring part 3