added logClose function