Fixed the Q-value write function