removing unneded console and also returning undefined for error instead of status code