organizing code and trying to integrate with button