Fixing logic errors with userid session param