cleaned up onClick function