Wrapping script blocks to functions