fixing detail design and code cleanup