implemented db logic and first page