You could make this a tiny bit shorter if you use get/2 here, as you can have just one code path.