Tested all possible database locations

Made a few formatting changes, but confirmed logic looks ok.