reorganized, improved variable names