some fixes to functions