Using plugin api function instead of previous mess.