finish the justify function