add pause function but it is buggy