fixing js browser memory leak