working OK. need to put some thresholds into vars