still playing around with global and local variables. added some experimental commented out code. i really should open another branch for that.