update to the code to work with latest version spark1.2