added functionality to purge and restore tasks