cleaned up examples
fixed logic error