reorganized code. integrated menu