reorganised code into more js files