refactoring, testing, history jpql fixed