fixing imagecount initialization bug