You cannot rely too much on ChatGPT for refactoring. Basically, you still need to understand ur code. It will sometimes get it wrong, sometimes get it right. You have to be able to catch these mistakes. But generally, ChatGPT is a really good companion.