Fixed null Pointer error on cycle