added check around pause function