begin rewriting as AngularJS app