Code works fine, but one last minor bug that needs to be fixed