Added diagonal logic