moved data access code to class
moved data access code to class