added emptying at the end