Refactored to .js-file, added caching