validation, bugs and error fix