modified database code to use env variables