Used old javascript from Daniel's original