remove unneeded function argument
improve selector performance
use local variable for document