Refactor
Final version