second iteration with rostislav's updates