added function code

completed assignment