Moved logging to after UID check