Add boundary handling