dataPrep function update

Better commenting and bugfixing