bugx fixed; c version is correct AND fast