move authCheck code into seperated file: lib/authCheck.js