added some code for function validation