fixed broken stuff and refactored the respository