Fixed error that was happening on page load