More work on the function, STILL INCOMPLETE, DON'T USE!