reorganized reactive code a bit