Improved before_install hook