This code completes problem set 2 of cs50x