Add form and socket logic