optimization and more checks