Some changes - 

FIxed a bug : global variable issue