add parent path checking before calculation