fixed after merge;
refactored
completed writemessaage;