added checks for regular files