Added better logic to code count target