Fixed bug with  on outside of correct if statement, causing exit prior to insert