formated code and removed carriage return
added listeners