cleaned up some js code