updating on method so that it monitors elements dynamically