refactor to implement dataset