function for setting transparency