Got a semi working version of counting done

Still needs some bugs fixed