refactor to use ngresource