copied with fixes