implement flip method