Fixed a bug, seems like all works pretty well now. Need to benchmark the new sim function