Room to optimize code

Thanks for trying to post your code correctly, but you used Blockquote tags (the '' icon) rather than code tags (the </> icon)

See How to get the best out of this forum for advice on using code tags