make refactor code and add repository class