Added more db logic, but not working properly to this state