declare ifcount in script instead of piping it in.