Place the allocation directly before the check for success. Use the same order for server and client atoms.