repair collect function
refactoreing