Put code that deals with default database selection in separate