big refactor for decryption