small refactoring in models/deployment

extracted common lines into a method and small refactoring of the methods involved

saved 5 lines ;-)