refactored pal_2