Add check for empty data array
Start on perturbation algorithm, doesnt quite work yet.

Just ending the night with a commit... :(