fixing bug of comparing different types