code reviewed and fixed