reworked storing to and displaying from database