Corrected minor logic error