added db function to log attempt