implemented error checking + database credentials