added check for preventDefault