working chat program - just a bit messy