Added safety guard to print correctly