extracted some js code to separate files