write movements to database