Refactor code for installing