cleaned up code and made button more powerful