barebones version with global vars