2nd challenge done

- made the functions more composable and useful