This code was a challenge given by function space