porting to appengine and refactoring part 2