updated code and code to state trace