refactor angular factories