sorting out some code