boolean section test
fixed section termination bug

code is still rather ugly but is fully working for now