Added some database access in click handlers