removed random() and use assoc in query for logs