mostly working not fully robust yet