cleaned up, tested on flip