Resolved missing variable and refactored request tracking in server.js