Added cleanup functionality
Condensed the command chain