PERL-259 partially re-implemented write command logic