changed some ifs to else if