modified and added code to the functions