pass level to function