error with how onclick function was doing its thing