debug messages working but its a little complex.