optimise creating procedure
fix function type check error