Changing my code to match a working example