workaround with callbacks, concerned that I might have made use of evil global variable