>>523です
これでいいのかな...?

https://pastebin.com/4tiywkHV