combined final two functions into one - now button appears on second page AND works correctly woohoo