Added some logic (and fixed some grammar)