K-W algorith - working version, checking left and right bound of sampled function