updated code to make it compatible with pandas >=0.14