The original code for Shapemix