moved db init code outside of main