added db as globle variable