rewrite more elegant