fixed the installer and improved logic