bugfixing database access problems and adding delete function