added code to handle code redemption