fixed undefined + added loop + finished