updated the code to make it compatible with pandas >= 0.14