Added error checking for arguments and function names