corrected issues in first set of functions