re-implemented PR with recommended changes

from PR https://github.com/dalekjs/dalek/pull/35