changed code to use broadcast variables
added a method which takes SparkContext as parameter