completed new check offset

wrote avg2 function, a seperate shelvefile function and completed the
main function.