added begin function and handling