Final version of Angular JS Code