beginning of control p functionality