trying to port the complex numberwang algorithm