added end to function