javascipt moved to js file for DB access. not tested on db