Slightly rewrite and clean code