wrote code for functions