modified code to compile for spark core