Simplified Python code