Credits to the AngularJS seed and to my own implementation