Fixing boundary bug