Fixed key extraction
Reworked main.py