code for various analysis