fix#64

  Refactored the code for deploy_group function.
  Implemented two more helper functions.