refactory deploy script