replace deprecared code in python 2.6. The new code work for python 2.4