Refactor expand feature + fix perfomance bug