extract solution for easier copy-paste from github