Rewrite of get, must more simply using cases rather than nested ifs