Refactored and restricted encoding to prevent router related issues