added control flow for buttons