fix incorrect closure behaviour