changing callback to angular promise