Connecting 5V to OUTPUT

That could be dangerous. If the pin is in OUTPUT mode and in the LOW state and you have 5 V connected to it, that's a short. That will cause the current on the pin to exceed its maximum rating, which could cause permanent damage.