Fixed a missprint in the code.
Simplified the condition.