Added error logging
Added record count