bug fixes for p. still a weird dimesion error