As your code works, this question is off topic here. If there is a
problem with your code, then please focus your question on that. But otherwise, consider posting on
Code Review, but if you do, make sure to first read their guidelines and then revise your question accordingly. —
trincot 26 secs ago