Refactored to js style.