Fixed basic logic error