refactor py files