and you placed 'next' after 'endif' and before 'function' ?
_________________________