JS function and tool