1. database relations fixed
2. refactoring