Moved code for adding layer out of button event to own method