rewritting some code