refactor by using python better practise