fixing small bug in my implementation