Refactoring code, removing unecessary variables in .py