moved some code around....