remove extra endfunction statement