added semantic checking for functions