Adjusted csha function.