Refactor LocCounter with Simple recursion