modified answer 2 for non positive values