Simplify code, as per laanwj's suggestion