Remove access of undefined variable $result