added path to button, and factorized code