added events and improved adapter