catch regex err
cleanup
refactoring