Added invalid profile id logic