Implemented prepareCommand

replaced _get_finalCommand by prepareCommand