Made library check for DOM elements more generic