Refactor legos