First workable version with loading metadata from db