Converted coffee version to raw JS.