fixed errors to validate, moved clear inside main