added result database and refactored a bit