Server logic in but failing. Response not defined