Refactored using Webstorm 7.0.3