smoothed out javascript