some code sanitazing and optimizing done