code for required func