updated factory to make ajax call