add boundary case handling