Updated to run on python 3
Changed inserts to use {} rather than ++