refactored code, passing off interaction with post button