refactored cia code

an attempt make errors in tik/tmd values rarer in occurence