First working version of database access