add code to detect linearity