Change scope of count, and add syncronized to call getCount