added additional validity checks