got rid of the ugly global variable