working implementation. much room for improvement
stupid name