Refactor installation script