Refactors first and last button method