revise code to fit some python convention