code clean up from gerald