separated l and p functions
trap signal isn't working, so commented out for now