working on cleaning up code in scan link