added validation, fixed tab functionality