add type reference for generic function
bug fixed at error message
introducing typeof