Function for my second assignment