fixed logic error in block traversal