moved some code around to better organize