added memory monitoring