changed to use angular $resource