adding js version of the mine code.