bug fix for flip() and add an example