Fix code based on Hiroki's feedback