Fixed issue with placing code outside the function