fixed the ugly hack, made it even uglier by adding a global variable