Improve deploy logic