After you file

I am an international student and wrongly filed my 2021 tax return as a Resident instead of Non-resident using Tax Slayer and got a federal refund last year, which I guess I shouldn't have gotten as on my 2021 W2 there is no federal tax withheld. Now I used Sprintax to amend it and downloaded 1040 NR which it says I owe money to the IRS. So my question is is this right ? or did I mess up in filling my 1040 NR on sprintax? And how should I pay back the federal refund i got? I am in really need of some help as today the last date to file!