improved but stil has errors