added threshold func, unit tests coming soon