complete coding. ready for test