Made decode more dynamic