Rewrite with simpler approach