several changes on data access and refactor