Tested beta code and uncommented working flip code