fix bug 14, update code