history added, helper function print added