cleaned up the code some