Almost done, still cannot fully handle invalid inputs