Move if statement outside of the function; Make count variable global; Fix resulting errors in tests;