First simple implementation with empirical threshold
Added licence