WIP: Fixed flipping logic, but still doesn't work properly