fixed wrong comparison logic