reindented code
moved code to chatapp