Update: Less elegant, but I feel this is more readable.