formatted js, updated SQL to avoid NULL columns