fixed small bug, also added in for loop break