fix infinity bug