updated with some caching