merged my code with mikes