update some code from avim