Added event listener on database query