added cleanup call on failure