Added sample based flatness correction