Refactory of repo