bug fix and JSFiddle demo link added