code re-organized