UPD: complete implementation except for overlay