Updated APIController to fix fault with $function