fixed some function variable passing