Using global variables to signal instead of return