lines 248 and 265 updated (var changed to val) @vjovanov