added autogeneration function