optimize code before final experiment