fixing undefined variables
fixing indent
write any database messages / non critical errors to the log - don't pollute the browser