moved some code around into more logical places