Fixed logic bug

Simple changes to logical condition