small bug in previous code