make script compatible with both 2 and 3