I need to change the order status and order status history comment based on the last value of the status, currently i've set order status and comment status like this:
$event = $observer->getEvent();
$order = $event->getOrder();
// need to check the previous order status history comment
$history = $order->addStatusHistoryComment('', $order->getStatus());
$history->save();
// need to check last order status
$order->setData('status', $order->getStatus())->getResource()->saveAttribute($order, 'status');