added code to analyze s-curves