refactor angularjs example and pilvi