refactor data layer