Improved edit by using angular.copy()