Better amd implementation