remove "!= None" check in if-conditions, pythonify code
replace temp as variable name
style changes