added some validation and put function