completed code for correlation