moved functions to globals (+ change tab to spaces)