added some checks to avoide long running tasks