Trying to solve cost counter problem