Fixing variable and count declarations