Minor code rewrite