Re-factored for Angular.js/Firebase.io