some name changes and moving code around