algorithm is inspired by complexification.net; work in progress