fixing pause function