wrote in python 2.7