refactored to use ngresource