Finished implementing (counting is still not right)