added while loop, still buggy, fix pls