change all buut handling functions to one lambda function