first attempt at fixing flip encryption