write mode implemented. heavy debug