added some logic for key pegs