added db.close() in all views functions