improve mkpr function