Replaced Angular provider by factory to simplify the code