Change decode to use prototype instead of closure