do it like in go, check errors first (so !endswith and continue, that leaves nicer indentation