Added cleanup function
Completed Code