misc
refactored python code