made functions more easier and added comments