Attempt 3: Added some console.log calls for debugging