fixed bugs and added two new classes 'Validator' and 'Error'