refactored script of timo