added logs and fixed each bug with array slice.