Added comments
Separated DB from middleware