organizing some code