handling no conection to db and JS fixes