fix scope error introduced in cleanup