add p3
removed redundant nested conditions