moved printer function to callback