added class exists check and made singleton