unifying some code