Removed seg fault and now checking proper ending to the request