fixed threshold logic,added figure samples and functionality