move declaration to function