Initialize function with validity tests