added validations and fixed associations