Simplified code and possible copy problem fixed.