Added event listener and made the API standalone