Improve the code a bit (add one more check)