code updated with decryption