Optimize Inspect implementation