what exactly is going on here? If it''s writing status to a file, could it be moved to a separate function and called from here?