I can't figure out why my logic isn't working properly