Flat related query

Dear Sir, I have purchased a flat through bank finance and the bank has disbursed around 38 lakh to the builder. After full construction I was not satisfied with the architectural design of the said flat. Hence I talked with the builder about changing of the flat He agreed and the flat was cancelled through registered cancellation deed and a new flat in the same floor was alloted by the builder and agreement was also signed. When I went to the bank to inform about it, they said that the amount of Rs 38 lakh has to be repaid either by myself or the builder. The builder was also reluctant to repay to the bank. Simultaneously the builder again sold the flat to another customer. Then I approached another bank for take over of the previous flat but they refused that the builder did not posses RERA certificate. Later one bank agreed to finance for the new flat. I had a discussion with the builder that whatever outstand was there for the previous flat after disbursement from the bank for the new flat he will close the liabilities for the first flat. Now after getting the money if the builder does not repay, what can be done, as I will be paying EMI for the cancelled flat as well as new flat. Kindly suggest what legal action can be taken.