maybe use `case` there as you twice check ret and maybe extend it in future?