fixed errors with function name being undefined