add implementation for flip.