fix a bug in restore layout