added repository pattern and better design