Fixes minor bug reported by Jose

fixes logic error