finished code counting script
fixed some bugs