evalFunction method to simplify function calling and return value processing.