Added loggin to output files and fixed sampling - there were syntax as well as additions where subtractions should have been