re-structure to factory and service for data access and directive for the user interface