separating logic and creatig self-executable functions to take code out of the global scope