Fixed bug: incorrect checing