mv go() to core/functions. Improved function code