organized js code