Fixing boundaries functions