Renamed variables, organized the code a bit, added TODO for handling invalid input