before functionality