Slightly more elegant implementation