fix run order & optimize already-installed check