implem for append with P

also made priority checks in prepend better