Basic code is in place, but I made a logic error somewhere