optimize some code;