2343 - extracted cleanup to function