refactoring some of the js. now everything basically working...