Started working on a new function and added some minor changes