added flip stuff. needs just a bit more refining