Nitrates are GOOOD. Nitrites aren't but the usual cycle is high ammonia, then high nitrites, the ammonia falls, the nitrates start rising, the nitrites fall. Ideally the nitrites should be zero, as the ammonia. It maybe heading in that direction. High Nitrates should not hurt but there maybe an upper limit on them, check some of the permanent posts here on that...somebody else may differ on that. I just know that nitrates are where one WANTS to head for. It indicates the beneficial bacteria are working and converting the nitrites to nitrates. Are the fish showing any problems? If you have live plants they'll use the nitrates. Good luck! Believe it or not, the product Easy Balance really helps balance a tank bacterially. We were very skeptical but the danged stuff works, it really does, just squirt the suggested amount into the water. Amazing, something advertised that works. Wow. I am not saying rely on it instead of water changes etc but it can sure help in a worrisome situation by putting in the good stuff and getting rid of the bad. Hope that helps.
Hmmm, 40 ppm on the Nitrates is a good level according to one of the experts here so yours is abit high. What is in your tank? Any live plants? Bottom feeders? Are you overfeeding at all? Just trying to think what would spike the levels like that.