refactor the install logic