converting it iffe pattern to keep vars and functions out of global scope