improve effeciency of functions