Tried a version that is more functional: no-usage of eval.