Input validation

need to check this over again, but it is nearing completion