added pause and fixed bugs