Fix potential bug pointed out by Amnet