Any way I could optimize these 2 parts of my code?

@tiancar : Please check out this thread for how to post code on the forums, for future reference : Using code tags properly

:slight_smile: