reduced the code size by a few lines by inverting the condition