JavaScript Refactor with Constructors