Refactor and add socket response