add connections between models and refactor authorization