added cleanup logic