Modified is_pal
Added helper funcitons to improve readability