rewriting for some better code