cleaning up the crud in javascript, problem still with refresh