Added JS Factory function