did a lot of playing around
still has small errors
fixed problems during writing into database now working