all global variables, but it works