move var declarations to function start