updated close of db and linking db to user input