made safewords calculation slightly more Pythonic