Refactored for better compression on client side