Fixed formatting issues and added listeners