Python code: cleaning code