fix name bug (name variable was reused)