@riataman has a solution here that might be useful.