n=40 m=48 runs a bit faster(avg 11.9) and added skeleton for fringe cases in else statement