worked on 3.7 and minor changes to 2