add isUndefined function to check whether a value is undefined of not
add range function to produce a range of values
modified first rest functions; using range function instead of fol loop: