Fixed an error where it looked for the wrong field in SQL to get the
value Id therefore inserted zeros to the application_data table, and
constantly looked up SQL for the given value, slowing the program.