changed js to try fix TypeError