imported princeton implementation