Moved out logic for dealing with databases from restaurants file